package com.shengyuan.manage_os.old.ying.erpm;

import org.json.JSONException;

import com.shengyuan.manage_os.R;
import com.shengyuan.manage_os.old.ying.erpm.util.Utility;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class Actual_JX_ChuKuDan extends Actual_GC_CaiGouDan {

	protected EditText editText_shiwumingcheng, editText_danwei,editText_rukushuliang,  editText_zongjia;
	@Override
	public String MyID() {
		return getClass().getName();
	}
	@Override
	public void onClick(View view) {
		super.onClick(view);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate_copy(savedInstanceState);
		setContentView(R.layout.actual_form_jx_chukudan);
		InitControls();
	}
	@Override
	protected void SaveJsonData() {
		try {
			//super.SaveJsonData();
			IsJson1 = true; mFinished = 1; mPrintenabled = 0;
			JsonMyID();
			getTask();
			getCaiLiao();
			getDataExt();
			
			getGPS();
			getCurrentUser();		
			getMemo();
			save_pic();
		}catch (Exception e) {
		}
	}
	
	@Override
	protected void getDataExt() throws JSONException {
		super.getDataExt();
		
		if (editText_shiwumingcheng!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_shiwumingcheng), editText_shiwumingcheng.getText().toString());
		}
		if (editText_danwei!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_danwei), editText_danwei.getText().toString());
		}

		if (editText_zongjia!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_zongjia), editText_zongjia.getText().toString());
		}
		if (editText_rukushuliang!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_chukushuliang), editText_rukushuliang.getText().toString());
		}
		if (LoginActivity.pmUser!=null) {
			mJson.put( getString(R.string.title_actual_form_editText_info_bumen), LoginActivity.pmUser.Department);
		}
	}
	@Override
	public void Back() {
		this.finish();
	}

	@Override
	public void InitControls() {
		super.InitControls();
		editText_shiwumingcheng = (EditText) findViewById(R.id.editText_shiwumingcheng);
		editText_danwei= (EditText) findViewById(R.id.editText_danwei);
		//editText_rukudanjia= (EditText) findViewById(R.id.editText_rukudanjia);
		editText_zongjia= (EditText) findViewById(R.id.editText_zongjia);
		editText_rukushuliang= (EditText) findViewById(R.id.editText_rukushuliang);
		editText_shiwumingcheng.setOnLongClickListener(this);
	}
	
	@Override
	public Boolean IsPassed() {
		if (GpsButton_Gps!=null) {
			if (GpsButton_Gps.x ==0 && GpsButton_Gps.y==0) {
			Utility.MessageBox( this,GpsButton_Gps.hint );
			return false;
			}
		}
		if (!CheckEditEmpty(spinner_tasksource)) {
			return false;
		}
		if (!CheckEditEmpty(editText_shiwumingcheng)) {
			return false;
		}
		if (!CheckEditEmpty(editText_danwei)) {
			return false;
		}
		if (!CheckEditEmpty(editText_rukushuliang)) {
			return false;
		}
//		if (!CheckEditNumber(editText_rukudanjia)) {
//			return false;
//		}
		if (!CheckEditNumber(editText_zongjia)) {
			return false;
		}		
		if (!CheckEditEmpty(editText_shenpiren)) {
			return false;
		}	
		if (PictureButton_piaoju!=null && !PictureButton_piaoju.IsExist()) {
			Utility.MessageBox(this, PictureButton_piaoju.FIELD );
			return false;
		}
		return true;
	}
	
    @Override
	public boolean onLongClick(View view) {
    	super.onLongClick(view);
		switch (view.getId()) {
		case R.id.editText_shiwumingcheng:
			Utility.HideEditFouce(editText_shiwumingcheng);

			PopMenuFormField(editText_shiwumingcheng , "CaiLiaoMingCheng");
			break;
		}
		return true;
	}

}
